import {HYEventStore} from 'hy-event-store'
import {  getSongListData } from '../services/music-api'

const ranks = {
  0:"newRankInfo",
  1:"hotRankInfo",
  2:"createRankInfo",
  3:"fastRankInfo"
}
const rankStore = new HYEventStore({
  state: {
    hotRankInfo:{}, //1
    newRankInfo:{}, //0
    createRankInfo:{}, //2
    fastRankInfo:{}, //3
  },
  actions: {
   getRankSongInfo(ctx){
      for(let i = 0 ;i < 4 ; i++){
        getSongListData(i).then(res => {
          const result = res.playlist 
          ctx[ranks[i]] = result
        })
      }
   }
  }
})

export {
  rankStore,
  ranks
}
